<?php
include 'include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/MAIN.dwt.php" codeOutsideHTMLIsLocked="false" -->
  <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>JoshHughes.com NFL Football Pool</title>
    <!-- InstanceEndEditable -->
	<link rel="stylesheet" href="css/football.css" type="text/css">
    <script src="scripts/prototype.js" type="text/javascript"></script>
	<script src="scripts/scriptaculous.js" type="text/javascript"></script>
	<script type="text/javascript">
	// Dynamic Iframe loader
	function loadIframe(theFrame, theURL) {
		document.getElementById(theFrame).src=theURL;
	}
	
	// resizes Iframe according to content
	function resizeMe(obj){ 
	docHeight = mainContent.document.body.scrollHeight
	 obj.style.height = docHeight + 'px'
	 } 
	</script>
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >
	
		<?PHP include_once("layout/header.html"); ?>
		
	</div>
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >

			<!-- InstanceBeginEditable name="Contents" -->
			<?
				$error="<p><b>There has been an error processing your activation.</b></p>\n
				<p>Please refer to the activation e-mail sent to you and click the enclosed link.</p>\n";
				
				if (isset($_GET['id']))
				{
					dbConnect();
					$SQL="UPDATE Users SET flag='1' WHERE md5(Email)='$_GET[id]'";
					mysql_query($SQL) or die("Cannot query the database to update activity flag.<br/>");
					$num_rows = mysql_affected_rows();
					if ($num_rows == 1)
					{
						echo "<p><b>Thank you for activating your account.</b></p>\n";
						echo "<p>You can now <a href=\"index.php\">play in the pool</a>!</p>\n";
					}
					else
					{
						$SQL="SELECT count(*) FROM Users WHERE flag='1' AND md5(Email)='".$_GET[id]."'";
						mysql_query($SQL) or die("Cannot query the database to see if you've already activated this account.<br/>");
						$num_rows = mysql_affected_rows();
						if($num_rows == 1)
						{
							echo "<p><b>Your account has already been activated.</b></p>\n";
						}
						else
						{
							print $error;
							echo "here";
						}
					}
				}
				else
				{
					print $error;
				}
				?>
			<!-- InstanceEndEditable -->
			
			</div>
			<div id="leftcol" >
			
				<?PHP include_once("layout/left_column.php"); ?>
		
			</div>
			
		</div>
		
		<div id="footer" >
		
			<?PHP include_once("layout/footer.html"); ?>
			
		</div>
</div>
</body>
<!-- InstanceEnd --></html>